/// @tags: Splay
#include <algorithm>
#include <cctype>
#include <cstdio>

namespace BlueQuantum {

int const N = 1e5 + 5;

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

struct Node {
  int val, siz;
  Node *fa, *ch[2];
} tr[N], *root[N];

int n, m, q;
int f[N];

int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }

inline bool iden(Node *x) { return x->fa->ch[1] == x; }

inline void pushup(Node *x) {
  x->siz = 1;
  if (x->ch[0]) x->siz += x->ch[0]->siz;
  if (x->ch[1]) x->siz += x->ch[1]->siz;
}

inline void rotate(Node *x) {
  bool xtofa = iden(x);
  Node *fa = x->fa, *son = x->ch[!xtofa];
  if (fa->fa) fa->fa->ch[iden(fa)] = x;
  x->fa = fa->fa;
  fa->ch[xtofa] = son;
  if (son) son->fa = fa;
  fa->fa = x;
  x->ch[!xtofa] = fa;
  pushup(fa);
  pushup(x);
}

inline void splay(Node *x, int rt) {
  for (Node *fa; (fa = x->fa); rotate(x))
    if (fa->fa) rotate(iden(x) == iden(fa) ? fa : x);
  root[rt] = x;
}

inline void insert(Node *x, int rt) {
  Node *cur = root[rt], *fa = NULL;
  while (true) {
    fa = cur, cur = cur->ch[x->val > cur->val];
    if (!cur) {
      fa->ch[x->val > fa->val] = x;
      x->ch[0] = x->ch[1] = NULL;
      x->fa = fa, x->siz = 1;
      pushup(fa);
      splay(x, rt);
      break;
    }
  }
}

inline int rank(int rt, int k) {
  if (root[rt]->siz < k) return -1;
  Node *cur = root[rt];
  while (true) {
    if (cur->ch[0] && k <= cur->ch[0]->siz) cur = cur->ch[0];
    else if ((!cur->ch[0] && k == 1) || (cur->ch[0] && k <= cur->ch[0]->siz + 1))
      return splay(cur, rt), cur - tr;
    else
      k -= cur->ch[0] ? cur->ch[0]->siz + 1 : 1, cur = cur->ch[1];
  }
  return -1;
}

void solve(Node *x, int y) {
  if (x->ch[0]) solve(x->ch[0], y);
  if (x->ch[1]) solve(x->ch[1], y);
  insert(x, y);
}

inline void merge(int x, int y) {
  x = find(x), y = find(y);
  if (x != y) {
    if (tr[x].siz > tr[y].siz) std::swap(x, y);
    f[x] = y;
    solve(root[x], y);
  }
}

inline int main() {
  read(n), read(m);
  for (int i = 1; i <= n; ++i) read(tr[i].val), f[i] = i, root[i] = &tr[i], tr[i].siz = 1;
  for (int i = 1, u, v; i <= m; ++i) {
    read(u), read(v);
    merge(u, v);
  }
  read(q);
  char opt[2];
  for (int x, y; q; --q) {
    scanf("%s", opt);
    read(x), read(y);
    switch (opt[0]) {
      case 'Q':
        printf("%d\n", rank(find(x), y));
        break;
      case 'B':
        merge(x, y);
    }
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P3224 [HNOI2012]永无乡.in", "r", stdin);
  freopen("P3224 [HNOI2012]永无乡.out", "w", stdout);
#endif
#endif

  return BlueQuantum::main();
}